import React from 'react';
import { Alert } from 'react-native';
import { Scene, Actions } from 'react-native-router-flux';
import MyForm from './Form';
import store from '../models/activity';
import customers from '../../customer/models/customers';
import navBarStyle from '../../../components/navBarStyle';

const alert = Alert.alert;

const pressHandle = values => {
  store.addPolicy(values).then(data => {
    if (data) {
      alert('操作成功', '提交活动保单', [
        {
          text: '继续添加',
          onPress: () => Actions.refresh({ eventId: values.eventId })
        },
        { text: '返回', onPress: Actions.pop }
      ]);
    }
  });
};
module.exports = (
  <Scene
    key="addActivityPolicy"
    component={MyForm}
    path="edit/activity/policy"
    title="提交活动保单"
    hideTabBar
    onSubmit={pressHandle}
    store={store}
    customers={customers}
    {...navBarStyle}
  />
);
